//
//  STMNavigationViewController.m
//  StoreManagement
//
//  Created by centling on 16/5/11.
//  Copyright © 2016年 alfred. All rights reserved.
//

#import "STMNavigationViewController.h"

@interface STMNavigationViewController ()

@end

@implementation STMNavigationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [[UINavigationBar appearance] setBarTintColor:MAINGRAYCOLOR];

}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if (self.viewControllers.count > 0) { // 如果现在push的不是栈底控制器(最先push进来的那个控制器)
        viewController.hidesBottomBarWhenPushed = YES;
        
        UIButton *backButton=[[UIButton alloc]init];
        // 设置返回图片
        [backButton setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
        backButton.contentMode = UIViewContentModeScaleAspectFill;
        [backButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
        backButton.frame=CGRectMake(0, 0, 23, 23);
        viewController.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithCustomView:backButton];
        
    }
    
    [super pushViewController:viewController animated:animated];
}


- (void)back {
    [self popViewControllerAnimated:YES];
    [SVProgressHUD dismiss];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
